package project.messagestack;

import project.messagestack.utils.Logger;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class BootReceiver extends BroadcastReceiver {

  @Override
  public void onReceive(Context context, Intent intent) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    boolean startAtBoot = preferences.getBoolean("startOnBoot", false);
    if (startAtBoot) {
      context.startService(new Intent(context, MessageStackService.class));
      Logger.logInfo("Service started");
    } else {
      Logger.logInfo("Service not started");
    }

  }

}
